package com.yuch.service.impl;

import com.yuch.service.SendSMS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.io.File;

@Service
public class SendSMSImpl3 implements SendSMS {
    @Autowired
    private JavaMailSender javaMailSender;

    private String from ="3060186113@qq.com";

    private String to="ych4912@163.com";

    private String title="title";

    private String text="context";


    @Override
    public void sendsms() throws MessagingException {
        MimeMessage mimeMessage = javaMailSender.createMimeMessage();
        //set send file
        MimeMessageHelper heper = new MimeMessageHelper(mimeMessage, true);
        heper.setFrom(from);
        heper.setTo(to);
        heper.setSubject(title);
        heper.setText(text);

        File f1 = new File("D:\\Entertainment\\文章\\天涯kkndme神贴论房价.pdf");
        File f2 = new File("D:\\Entertainment\\图片\\1.jpg");

        heper.addAttachment(f1.getName(),f1);
        heper.addAttachment("belle.jpg",f2);

        javaMailSender.send(mimeMessage);




        javaMailSender.send(mimeMessage);
    }
}
